<template>
  <el-dialog v-model="dialogVisible" :destroy-on-close="true" width="70%" title="企业当家币流水帐">
    <ProTable ref="userTable" :columns="userColumns" :request-api="getCompanyCoinDetailVoApi" :init-param="initParam">
      <!-- 表格 header 按钮 -->
      <template #tableHeader>
        <el-button @click="dialogVisible = false">关闭</el-button>
      </template>
      <template #coinCnt="scope">
        {{ ((scope.row.coinCnt || 0) / 100).toFixed(2) }}
      </template>
      <template #optCnt="scope">
        <el-tag :type="scope.row.optCnt > 0 ? 'danger' : 'success'">
          {{ ((scope.row.optCnt || 0) / 100).toFixed(2) }}
        </el-tag>
      </template>
    </ProTable>
  </el-dialog>
</template>
<script setup lang="ts">
import { ref, reactive } from "vue";
import ProTable from "@/components/ProTable/index.vue";
import { ColumnProps } from "@/components/ProTable/interface";
import { getCompanyCoinDetailVoApi } from "@/api/modules/cpy/act";

//提交按钮，避免多次提交
const dialogVisible = ref(false);

const initParam = reactive({});

// interface AddUserDialogParam {}

const acceptParams = (): void => {
  dialogVisible.value = true;
};

// 表格配置项
const userColumns: Partial<ColumnProps>[] = [
  { type: "selection", width: 80, fixed: "left" },
  { type: "index", label: "#", width: 60 },
  {
    prop: "coinCnt",
    label: "当家币",
    width: 120
  },
  {
    prop: "optCnt",
    label: "流水",
    width: 120
  },
  {
    prop: "createDate",
    label: "操作时间",
    width: 200
  },
  {
    prop: "note",
    label: "说明",
    // search: { el: "input" },
    sortable: true
  }
];

//页面事件
// const emits = defineEmits(["refresh-list"]);

defineExpose({
  acceptParams
});
</script>
